//
//  UIColor+StockColorEntension.m
//  K线图自治
//
//  Created by LK-IOS on 2017/12/11.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "UIColor+StockColorEntension.h"

@implementation UIColor (StockColorEntension)

+ (UIColor *)colorWithHex:(UInt32)hex
{
    return [UIColor colorWithHex:hex alpha:1.f];
}

+ (UIColor *)colorWithHex:(UInt32)hex alpha:(CGFloat)alpha
{
    int r = (hex >> 16) & 0xFF;
    int g = (hex >> 8) & 0xFF;
    int b = (hex) & 0xFF;
    
    return [UIColor colorWithRed:r / 255.0f
                           green:g / 255.0f
                            blue:b / 255.0f
                           alpha:alpha];
}
///////K线颜色配置


+ (UIColor *)colorWithHexString:(NSString *)hexString
{
    NSString *cString = [[hexString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    
    if ([cString length] < 6) {
        return [UIColor clearColor];
    }
    
    if ([cString hasPrefix:@"0X"])
        cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];
    if ([cString length] != 6)
        return [UIColor clearColor];
    
    NSRange range;
    range.location = 0;
    range.length = 2;
    
    //r
    NSString *rString = [cString substringWithRange:range];
    
    //g
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    //b
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];
}
/**
 *  主文字颜色
 */
+(UIColor *)Stock_TextColor
{
    return [UIColor colorWithHexString:@"707f8c"];
}
+(UIColor *)Stock_BoxColor
{
    return [UIColor colorWithHexString:@"E3ECF4"];
}
+(UIColor *)Stock_BackColor
{
    return [UIColor colorWithHexString:@"F7F7F7"];
}
/**
 *  分时图走势线颜色
 */
+(UIColor *)Stock_TimeLineColor
{
    return [UIColor colorWithHex:0x60CFFF];
}

+(UIColor *)Stock_TimeLineBackColor
{
    return [UIColor colorWithHex:0x60CFFF alpha:0.1f];
}

/**
 势移动时显示的纵线和横线的颜色
 */
+(UIColor *)Stock_GesTureLineColor
{
    return [UIColor colorWithHexString:@"FFA500"];
}

/**
 分时图背景线颜色
 */
+(UIColor *)Stock_TimeBackLineColor
{
    return [UIColor colorWithHexString:@"ededed"];
}

/**
 分时图圆圈填充颜色
 */
+(UIColor *)Stcok_TimeCycleFillColor
{
    return [UIColor colorWithHexString:@"d96c9c"];
}

/**
 价格上涨颜色
 */
+(UIColor *)Stock_PriceUpColor
{
    return [UIColor colorWithHexString:@"FC735E"];
}
/**
 价格下跌颜色
 */
+(UIColor *)Stock_PriceDownColor
{
    return [UIColor colorWithHexString:@"58E62C"];
}
/**
 移动手势时，显示的label的背景色
 */
+(UIColor *)Stock_GesTureLabelBackColor
{
    return [UIColor colorWithHex:0x4A90E2];
}



/**
 MA5颜色
 */
+(UIColor *)Stock_MA5Color
{
    return [UIColor colorWithHexString:@"FFC911"];
}

/**
 MA10颜色
 */
+(UIColor *)Stock_MA10Color
{
    return [UIColor colorWithHexString:@"4DD5F8"];
}

/**
 MA25颜色
 */
+(UIColor *)Stock_MA25Color
{
    return [UIColor colorWithHexString:@"CA69EF"];
}

@end
